package com.shangyitong.service_oss.controller;

import com.shangyitong.Result;
import com.shangyitong.service_oss.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
@RequestMapping("/api/oss/file")
public class FileApiController {
    @Autowired
    private FileService fileService;
    /**
     * 上传文件到阿里云oss
     * @param file
     * @return
     */
    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file){
        String url = fileService.fileUpload(file);
        return Result.ok(url);
    }
}
